package com.lty.jeeg.server.modules.tms.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import org.springframework.stereotype.Repository;

import com.lty.jeeg.server.modules.tms.model.Matters;

/**
 * @author : LTY
 * @date : 2019-04-03 15:00:28
 * Description :
 */
@Mapper
@Repository
public interface MattersDao {

    /**
     * 根据ID获取
     *
     * @param id ID
     * @return bean
     */
    @Select("select * from tms_matters t where t.id = #{id}")
    Matters getById(Long id);

    /**
     * 删除
     *
     * @param id ID
     * @return 1/0
     */
    @Delete("delete from tms_matters where id = #{id}")
    int delete(Long id);

    /**
     * 修改
     *
     * @param matters ID
     * @return 1/0
     */
    int update(Matters matters);

    /**
     * 保存
     *
     * @param matters bean
     * @return ID
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into tms_matters(taskId, msg, createBy) values(#{taskId}, #{msg}, #{createBy})")
    Long save(Matters matters);

    /**
     * 计数
     *
     * @param params 筛选条件
     * @return 总数
     */
    int count(@Param("params") Map<String, Object> params);

    /**
     * 列表
     *
     * @param params 筛选条件
     * @param offset 页码
     * @param limit  分页数目
     * @return beanList
     */
    List<Matters> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);

    /**
     * 全部动态
     * @return beanList
     */
    List<Matters> listAll(@Param("taskId") Long taskId);
}
